package JeuInterfaces;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;


public class ChoixPartie extends JDialog {

	private String versionJeu;
	private JPanel container;
	
	public ChoixPartie(String version) {
		this.setSize(new Dimension(250,45));
		this.setTitle("Type de partie");
		this.setLayout(new BorderLayout());
		versionJeu = version;
		initComposants();
		this.setLocationRelativeTo(null);
		this.setResizable(false);
		this.pack();
		this.setVisible(true);
		
	}

	private void initComposants() {
		
		container = new JPanel();
		container.setPreferredSize(new Dimension(250,45));
		container.setLayout(new GridLayout(1,2));
		container.setBorder(BorderFactory.createTitledBorder("Type de partie"));
		JButton local  = new JButton("Local");
		JButton reseau = new JButton("Reseau");
		local.setPreferredSize(new Dimension(120,35));
		reseau.setPreferredSize(new Dimension(120,35));
		local.setActionCommand("local");
		reseau.setActionCommand("reseau");
		local.addActionListener(new FenetreJoueur());
		local.setActionCommand("local");
		reseau.addActionListener(new FenetreJoueur());
		reseau.setActionCommand("reseau");
		container.add(local);
		container.add(reseau);		
		this.setContentPane(container);
	}
	
	class FenetreJoueur implements ActionListener{
		@Override
		public void actionPerformed(ActionEvent e) {
			if(e.getActionCommand().equals("reseau"))
				;//	TODO new PartieReseauInfos();
			else if (e.getActionCommand().equals("local")){
				ChoixPartie.this.setVisible(false);
				new PartieLocalInfos(versionJeu);
			}
		}	
	}
	
}
